home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-01-11 | 3.5 KB | 111 lines | [TEXT/CWIE] |
- // TNetworkEndpointDescriptor.cp - Macintosh OpenTransport network Endpoint Descriptor class object
- //
- // Apple Macintosh Developer Technical Support
- // Written by: Vinne Moscaritolo
- //
- // Copyright (work in progress) Apple Computer, Inc All rights reserved.
- //
- // You may incorporate this sample code into your applications without
- // restriction, though the sample code has been provided "AS IS" and the
- // responsibility for its operation is 100% yours. However, what you are
- // not permitted to do is to redistribute the source as "DSC Sample Code"
- // after having made changes. If you're going to re-distribute the source,
- // we require that you make it clear in the source that the code was
- // descended from Apple Sample Code, but that you've made changes.
- //
-
- #include "TNetworkEndpointDescriptor.h"
- #include "TNetworkException.h"
-
- #include "TAddrInet.h"
-
-
- // ---------------------------------------------------------------------------
- // ~TNetworkEndpointDescriptor
- // ---------------------------------------------------------------------------
- // Destructor
- TNetworkEndpointDescriptor::~TNetworkEndpointDescriptor()
- {
- if(fAddress) delete fAddress;
- if(fConfig) OTDestroyConfiguration(fConfig);
- }
-
-
- // ---------------------------------------------------------------------------
- // Stream
- // ---------------------------------------------------------------------------
- // write out descriptor info to stream
-
- void* TNetworkEndpointDescriptor::Stream()
- {
- return nil;
- }
-
- // ---------------------------------------------------------------------------
- // Unstream
- // ---------------------------------------------------------------------------
- // read in descriptor info from stream
-
-
- void TNetworkEndpointDescriptor::Unstream(void* in)
- {
- // ADD REAL CODE HERE
- ThrowIfOTInvalidConfig( fConfig = ::OTCreateConfiguration("tcp" ) );
- fAddress = new TAddrInet(kOTAnyInetAddress, 80);
- fState = S_INIT;
-
- }
-
-
- // ---------------------------------------------------------------------------
- // GetConfiguration
- // ---------------------------------------------------------------------------
- // Get Session Configutaration
-
- OTConfiguration* TNetworkEndpointDescriptor::GetConfiguration() const
- {
- ThrowIfOTInvalidConfig(fConfig);
-
- return OTCloneConfiguration( fConfig );
- }
-
-
-
- // ---------------------------------------------------------------------------
- // GetLocalAddress
- // ---------------------------------------------------------------------------
- // Get Session Local Address
-
- TAddr* TNetworkEndpointDescriptor::GetLocalAddress()
- {
- if( fState != S_INIT) ThrowMsg ("TNetworkEndpointDescriptor::GetLocalAddress - Not Initilized");
- return fAddress;
- }
-
- // ---------------------------------------------------------------------------
- // TNetworkEndpointDescriptor::Filter( call )
- // ---------------------------------------------------------------------------
- // Do you want to accept this connection
-
- Boolean TNetworkEndpointDescriptor::Filter(TCall* callInfo)
- {
- return true;
- }
-
-
-
- // ---------------------------------------------------------------------------
- // TNetworkEndpointDescriptor::ValidateBind( reqAddr, retAddr )
- // ---------------------------------------------------------------------------
- // Check if bind was acceptable
-
- Boolean TNetworkEndpointDescriptor::ValidateBind (TBind* reqAddr, TBind* retAddr)
- {
- InetAddress* request = (InetAddress*) reqAddr->addr.buf;
- InetAddress* reply = (InetAddress*) retAddr->addr.buf;
-
- return ( request->fPort == reply->fPort ); ///**** FIX THIS LATER *****
- }
-
-
-